/**
 * Created by yyj on 2015/10/28.
 */

$(function(){

    //点击关闭按钮
    $('.press_btn2.Close').click(function(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    })
    //点击保存按钮
    $('.press_btn1').click(function(){
    	saveHostGroup();
    });
});

function saveHostGroup() {
    var name = $("input[name='name']").val();
    if (name == "") {
        layer.msg("群组名不能为空", {
            time : 1500
        });
        return;
    }
    $.ajax({
        url:webPath+ "/radar/hostGroup/saveHostGroup.do",
        type : "post",
        dataType:"json",
        data:{
            "name":name
        },
        async:false,
        beforeSend : function() {
            $(".press_btn1").attr("disabled", "disabled");
        },
        error : function(data) {
        	alert("请求错误");
        },
        success : function(json) {
            var code = json.code;
            var result = json.errorMessage;
            if (code != null && code == "200"){
                    layer.msg(result, {time:1000},
                        function(){
                    parent.paging(1);// 调用父窗口的方法
                    var index = parent.layer.getFrameIndex(window.name);
                    setTimeout('parent.layer.close('+index+')',1001);
                });
            }else{
                layer.alert(result);
            }
        }
    });
}





